<template>
  <div>

    <div class="formVerify">
      <van-form @submit="onSubmit">
  <van-field
    v-model="username"
    name="用户名"
    label="用户名"
    placeholder="用户名"
    :rules="[{ required: true, message: '请填写用户名' }]"
  />
  <van-field
    v-model="password"
    type="password"
    name="密码"
    label="密码"
    placeholder="密码"
    :rules="[{ required: true, message: '请填写密码' }]"
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit">登录</van-button>
  </div>
</van-form>
    </div>



  </div>
</template>

<script>
import {Notify} from "vant"
export default {
  data() {
    return {
      username: 'user123',
      password: 'user123',
    };
  },
  methods: {
    onSubmit() {
      // console.log('submit', values);
      this.$axios({
        method:'POST',
        url:'/wx/auth/login',
        data:{
        "username": this.username, 
        "password": this.password, 
        },
      }).then(res=>{
        // console.log(res.data);
        if(res.data.errno===0){
        localStorage.setItem('X-Litemall-Token',res.data.data.token)  
        window.history.back()      
        Notify({ type: 'success', message: res.data.errmsg });
        }
        else if(res.data.errno!==0){
          Notify({ type: 'danger', message: res.data.errmsg });
        }
        
      })
    },
  },
}
</script>

<style>
.formVerify{
  margin-top: 35vh;
  padding-top: 60px;
  display: flex;
  justify-content: center;
  background-color: #ffffff;
  border-radius: 30px;
  box-shadow: 0px 0px 12px 0px #c0c0c0;
}
</style>